from app.models import db
from datetime import datetime

class AssetRiskCache(db.Model):
    __tablename__ = 'asset_risk_cache'
    asset_id    = db.Column(db.BigInteger, primary_key=True)
    asset_name  = db.Column(db.String(255), nullable=False)
    risk_score  = db.Column(db.Numeric(5,4), nullable=False)
    amp         = db.Column(db.Float, nullable=False, default=0.0)
    turn        = db.Column(db.Float, nullable=False, default=0.0)
    latest_price = db.Column(db.Float, nullable=False, default=0.0)
    buy_price   = db.Column(db.Float, nullable=False, default=0.0)
    pos=db.Column(db.Float, nullable=False, default=0.0)
    quantity=db.Column(db.BigInteger, nullable=False, default=0)
    computed_at = db.Column(db.DateTime, nullable=False, default=datetime.now)
